package in.co.codedoc.sql.mapping;

import in.co.codedoc.cg.annotations.DBType;
import in.co.codedoc.cg.annotations.IsADBOutputColumnMap;
import in.co.codedoc.sql.DBOutputColumnMap;
import in.co.codedoc.time.Time;

import java.sql.ResultSet;
import java.sql.SQLException;

@IsADBOutputColumnMap(javaType=Time.class,dbType=DBType.INT)
public class IntTimeOutputColumnMap
	extends DBOutputColumnMap
	implements ObjectOutputColumnMap
{

	@Override
	public void ReadColumn(int index, ResultSet rs)
		throws SQLException
	{
		int time = rs.getInt(index);
		
		if(rs.wasNull())
		{
			SetWasNull();
		}
		else
		{
			this.time = new Time(time); 
		}
	}

	@Override
	public Object GetValue()
	{
		return time;
	}
	
	private Time time;
}
